package cn.wolfcode.luowowo.mgrsite.controller;

import cn.wolfcode.luowowo.article.domain.Travel;
import cn.wolfcode.luowowo.article.query.TravelQuery;
import cn.wolfcode.luowowo.article.service.ITravelService;
import cn.wolfcode.luowowo.common.util.AjaxResult;
import com.alibaba.dubbo.config.annotation.Reference;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("travel")
public class TravelController {
    @Reference
    private ITravelService travelService;

    @RequestMapping("list")
    public String list(Model model,@ModelAttribute("qo") TravelQuery qo){
        model.addAttribute("pageInfo",travelService.query(qo));
        return "travel/list";
    }

    @RequestMapping("updateState")
    @ResponseBody
    public AjaxResult updateState(Long id,int state){
        travelService.updateState(id,state);
        return new AjaxResult();
    }

    @RequestMapping("getById")
    @ResponseBody
    public AjaxResult getById(Long id){
        Travel travel = travelService.get(id);
        AjaxResult result = new AjaxResult();
        result.setData(travel.getTravelContent().getContent());
        return result;
    }

}
